package client.start;
import java.io.*;
import java.net.*;

public class Client {

	public Client(){
		try{
			//Socket socket = new Socket("14.49.43.45",2222);
			Socket socket = new Socket("localhost",3123);
			InputStream is = socket.getInputStream();
			OutputStream os = socket.getOutputStream();
			BufferedReader br = new BufferedReader(new InputStreamReader(is));
			BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os));
			BufferedReader keybord = new BufferedReader(new InputStreamReader(System.in));
			
			System.out.print("메시지를 입력하세요 : ");
			String inmessage = keybord.readLine();
			bw.write(inmessage+"\n");
			bw.flush();
			System.out.println(inmessage+"전송됨");
			String message = br.readLine();
			System.out.println("서버메시지"+message);
			
		}catch(UnknownHostException unhe){
			System.out.println("호스트를 찾을수 없습니다");
		}catch(IOException ie){
			System.out.println("포트가 사용중입니다.");
		}
	}
	
	public static void main(String[] art){
		new Client();
	}
}
